package com.byron.media.server.logic;

import com.byron.media.server.enums.Args;
import com.byron.media.server.handlers.MediaSession;
import com.byron.media.server.model.MediaHeaderObj;
import io.netty.channel.ChannelHandlerContext;

public class UnregHandler implements IMediaHandler {

    @Override
    public void handle(MediaSession session, ChannelHandlerContext ctx, MediaHeaderObj header) {
        if(header.getArgs() == null){
            return;
        }
        String groupName = (String) header.getArgs().get(Args.GROUP_NAME);
        boolean sender = (boolean) header.getArgs().getOrDefault(Args.SENDER, false);
        String device = (String) header.getDevice().get("id");

        session.inactive(device, groupName, sender);
        ctx.fireChannelReadComplete();
    }
}
